# -*- coding:utf-8 -*-
import service.cubeinfo.crcrunner as cubeinfo
import service.sharerank.srcrunner as sharerank
import service.stockdebate.sdcrunner as stockdebate
import service.stocknews.sncrunner as stocknews
import service.stockprice.spcrunner as stockprice
import datetime
import service.initsocket.loadStockInfo as stock_info
import service.initsocket.loadStockTag as stock_tag
from service.initsocket import loadSSE
__author__ = 'shudong.msd'

# 开始抓取
filepath = u'G:/毕业设计/数据/排行榜/'+str(datetime.date.today())+'.xls'

# 如果有新增的股票则加入股票信息
if stock_info.init_stock() > 0:
    # 更新市值
    print stockprice.update_mv()
    # 更新板块
    stock_tag.init_stock_plate()
elif datetime.date.today().day in (7,15,20,25,1):
    # 更新市值
    print stockprice.update_mv()

# 大盘价格
loadSSE.loadSSE()

# 抓取排行榜
sharerank.writeToDB()
sharerank.writeToDB_hot_asc()
sharerank.writeToExcel(filepath)

# 抓取价格
# stockprice.writeToDB()
print stockprice.writeToDB_xueqiu()

# 抓取组合信息
print cubeinfo.write_cube_name()
print cubeinfo.writeToDBWithRank()
print cubeinfo.writeToDBWithInfo()
print cubeinfo.writeStockGroupForCube()

# 抓取新闻
print stocknews.write_sina_news()
print stocknews.write_east_news()

# 抓取股吧博客
print stockdebate.write_debate_to_db()
print stockdebate.write_east_debate_to_db()

